package org.gd.spring.jdbc;

import org.gd.hellojaxb.interfaces.XmlAble;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.xml.bind.JAXBException;
import java.io.IOException;
import java.util.List;

/**
 <pre>

 CREATE TABLE `customer` (
 `CUST_ID` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
 `NAME` VARCHAR(100) NOT NULL,
 `AGE` INT(10) UNSIGNED NOT NULL,
 PRIMARY KEY (`CUST_ID`)
 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

 </pre>
 */
public class App {

    public static void main(String...args) throws JAXBException, IOException {
        ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Module.xml");
        CustomerDAO customerDAO = context.getBean("customerDAO", CustomerDAO.class);

        Customer customer = new Customer("mkyong2", 100);
        //customerDAO.insert(customer);

        System.out.println();
        System.out.println();
        for(XmlAble c: customerDAO.getAllCustomers()) {
            System.out.println(c.toXml());
        }
    }
}
